<?php
namespace Home\Controller;
use Think\Controller;
class AdminloginController extends Controller {
   

    public $adminuser;
    
    public function __construct() {
           parent::__construct();
           $this->adminuser = M('aduser');
    }
    
    public function login() {              
            $this->display();
        }

    public function dologin(){
         if(IS_POST) {
            $username = $_POST['userName'];
            $pwd = $_POST['psd'];
            $code = $_POST['verify'];
            $verif = new \Think\Verify();
         if(!$verif->check($code)) {
                $this->error('请输入正确的验证码');
            }
         }
            $where['username'] = $username;
            $where['pwd'] = $pwd;
            $arr = $this->adminuser->field('id')->where($where)->find();

         if($arr) {
            $_SESSION['username'] = $username;
            $_SESSION['adminid'] = $arr['id'];
            $this->success('登陆成功',U('Home/Adminlogin/succ'));
             } else {
                $this->error('密码错误或者用户不存在');
         }
     }
 
     public function succ() {
             $this->display();
     }


}

   
